home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / DATATYPE / QUEUE2.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-09  |  1KB  |  41 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; queues #2 - the circular queue
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBDEF, EFLIBINI, EFLIBDAT;
  10.  
  11.  
  12. var MyQueue : QueueObjectType; Index, Number : integer;
  13.  
  14. begin
  15.      WriteLn ('* Circular queue demonstration *');
  16.  
  17.      { Initializes queue and stores 25 integer numbers in structure }
  18.      with MyQueue do begin
  19.           { Initialize a circular queue with access restriction }
  20.           InitializeQueue (SizeOf(Integer), TRUE, FALSE);
  21.                           { Element size }        { Access restriction }
  22.                                             { Circular }
  23.  
  24.           { Place numbers in queue }
  25.           for Index := 25 downto 1 do Store (Index);
  26.  
  27.           { Reverse entire queue - will give the same result as a replacement
  28.             of the for-loop interval "25 downto 1" with "1 to 25". }
  29.           Reverse;
  30.  
  31.           { Display queued data and recycle 8 times }
  32.           for Index := 1 to 200 do begin
  33.               Retrieve (Number);
  34.               Write (Number:5);
  35.           end;
  36.  
  37.           WriteLn;
  38.  
  39.           Intercept;
  40.      end;
  41. end.